package com.baitai.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baitai.common.annotation.Log;
import com.baitai.common.core.controller.BaseController;
import com.baitai.common.core.domain.AjaxResult;
import com.baitai.common.enums.BusinessType;
import com.baitai.system.domain.SysUserZcyx;
import com.baitai.system.service.ISysUserZcyxService;
import com.baitai.common.utils.poi.ExcelUtil;
import com.baitai.common.core.page.TableDataInfo;

/**
 * zcyx备用用户
 * Controller
 *
 * @author xx
 * @date 2024-12-01
 */
@RestController
@RequestMapping("/system/zcyx")
public class SysUserZcyxController extends BaseController {
    @Autowired
    private ISysUserZcyxService sysUserZcyxService;

    /**
     * 查询zcyx备用用户
     * 列表
     */
    @PreAuthorize("@ss.hasPermi('system:zcyx:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUserZcyx sysUserZcyx) {
        startPage();
        List<SysUserZcyx> list = sysUserZcyxService.selectSysUserZcyxList(sysUserZcyx);
        return getDataTable(list);
    }

    /**
     * 导出zcyx备用用户
     * 列表
     */
    @PreAuthorize("@ss.hasPermi('system:zcyx:export')")
    @Log(title = "zcyx备用用户 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysUserZcyx sysUserZcyx) {
        List<SysUserZcyx> list = sysUserZcyxService.selectSysUserZcyxList(sysUserZcyx);
        ExcelUtil<SysUserZcyx> util = new ExcelUtil<SysUserZcyx>(SysUserZcyx.class);
        util.exportExcel(response, list, "zcyx备用用户数据");
    }

    /**
     * 获取zcyx备用用户
     * 详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:zcyx:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysUserZcyxService.selectSysUserZcyxById(id));
    }

    /**
     * 新增zcyx备用用户
     */
    @PreAuthorize("@ss.hasPermi('system:zcyx:add')")
    @Log(title = "zcyx备用用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUserZcyx sysUserZcyx) {
        return toAjax(sysUserZcyxService.insertSysUserZcyx(sysUserZcyx));
    }

    /**
     * 修改zcyx备用用户
     */
    @PreAuthorize("@ss.hasPermi('system:zcyx:edit')")
    @Log(title = "zcyx备用用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserZcyx sysUserZcyx) {
        return toAjax(sysUserZcyxService.updateSysUserZcyx(sysUserZcyx));
    }

    /**
     * 删除zcyx备用用户
     */
    @PreAuthorize("@ss.hasPermi('system:zcyx:remove')")
    @Log(title = "zcyx备用用户", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysUserZcyxService.deleteSysUserZcyxByIds(ids));
    }
}
